#include "../include/gps_utils.h"
#include "../include/media_defs.h"

pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;

volatile int run_a = 1; // 控制GPS线程（保留为兼容性）
volatile int run_b = 0; // 控制多媒体线程
volatile int run_gps = 0; // 控制GPS线程
volatile int run_sensor = 0; // 控制传感器线程

pthread_t media_thread, gps_thread, sensor_thread;

// GPS线程
void* function_gps_thread(void* arg) {
    while (run_gps) {
        GPS_Background();
        usleep(100000);
    }
    pthread_exit(NULL);
    return NULL;
}

// 多媒体线程
void* function_b_thread(void* arg) {    
    mpg123_handle *mh = NULL;
    ao_device *device = NULL;
    background_play(mh, &device);
    return NULL;
}

// 传感器线程
void* function_sensor_thread(void* arg) {
    while (run_sensor) {
        VehicleSensor_Background();
        usleep(100000);
    }
    return NULL;
}

// 函数a线程（保留为兼容性，当前未使用）
void* function_a_thread(void* arg) {
    while (run_a) {
        GPSNavigator_Foreground();
        usleep(100000);
    }
    return NULL;
}